/*
ID: brodyzt1
PROG: ride
LANG: C++
*/

#include <iostream>
#include <fstream>

using namespace std;

int stringValue (string inputString)
{
    int value = (int)inputString[0] - 64;
    for (int i = 1; i < inputString.length(); i++) {
        value *= (int)inputString[i] - 64;
    }
    value = value % 47;
    cout << value;
    return value;
}

int main(int argc, const char * argv[])
{
    ifstream input;
    ofstream output;
    input.open("ride.in");
    output.open ("ride.out");
    string comet, group;
    input >> comet >> group;
    cin >> group >> comet;
    if (stringValue(comet) == stringValue(group)) {
        output << "GO\n";
    } else {
        output << "STAY\n";
    }
    input.close();
    output.close();
    return 0;
}

